﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:RiaMVVM_Example_Models="clr-namespace:RiaMVVM.Example.Models" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" x:Class="RiaMVVM.Example.MainPage"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
	<UserControl.Resources>
		<RiaMVVM_Example_Models:MainModel x:Key="MainModelDataSource" d:IsDataSource="True"/>
	</UserControl.Resources>

	<UserControl.DataContext>
		<Binding Source="{StaticResource MainModelDataSource}"/>
	</UserControl.DataContext>

	<i:Interaction.Behaviors>
		<ei:DataStateBehavior Binding="{Binding GetProductsOperation.ExecuteBusy, Mode=OneWay}" Value="True" TrueState="LoadingState" FalseState="DefaultState"/>
	</i:Interaction.Behaviors>

    <Grid x:Name="LayoutRoot" Background="White">
    	<VisualStateManager.VisualStateGroups>
    		<VisualStateGroup x:Name="VisualStateGroup" ei:ExtendedVisualStateManager.UseFluidLayout="True">
    			<VisualStateGroup.Transitions>
    				<VisualTransition GeneratedDuration="0:0:0.2"/>
    			</VisualStateGroup.Transitions>
    			<VisualState x:Name="DefaultState"/>
    			<VisualState x:Name="LoadingState">
    				<Storyboard>
    					<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="border">
    						<DiscreteObjectKeyFrame KeyTime="0">
    							<DiscreteObjectKeyFrame.Value>
    								<Visibility>Visible</Visibility>
    							</DiscreteObjectKeyFrame.Value>
    						</DiscreteObjectKeyFrame>
    					</ObjectAnimationUsingKeyFrames>
    				</Storyboard>
    			</VisualState>
    		</VisualStateGroup>
    	</VisualStateManager.VisualStateGroups>
    	<VisualStateManager.CustomVisualStateManager>
    		<ei:ExtendedVisualStateManager/>
    	</VisualStateManager.CustomVisualStateManager>
    	<Button Content="Load Products" HorizontalAlignment="Left" VerticalAlignment="Top" Width="94" Margin="16,12,0,0" Command="{Binding GetProductsOperation.ExecuteCommand, Mode=OneWay}"/>
    	<ListBox Margin="126,13,10,8" ItemsSource="{Binding GetProductsOperation.Result, Mode=OneWay}" DisplayMemberPath="Name"/>
    	<Border x:Name="border" HorizontalAlignment="Left" Margin="95,129,0,0" VerticalAlignment="Top" Background="#FFE7E7E7" Padding="6,12,9,8" Visibility="Collapsed" >
    		<TextBlock TextWrapping="Wrap" Text="Loading..." Height="16" Width="55"/>

    	</Border>

    </Grid>
</UserControl>
